<?php

use Illuminate\Http\Request;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

// 需要登录的接口
Route::middleware(['auth:api'])->group(function () {
    // 获取用户信息
    Route::get('/me/info', 'UserInfoController@getUserInfo');

    // 更新用户信息
    Route::put('/me/info', 'UserInfoController@userInfo');

    // 我的圈子和专辑列表
    Route::get('/me/list', 'UserInfoController@list');

    // 上传图片
    Route::post('upload', 'UploadController@uploadSomeImage');

    // 添加专辑名
    Route::post('/album','AlbumController@add');

    // 注册圈子
    Route::post('/group', 'GroupController@add');

    // 加入圈子
    Route::post('/group/join', 'GroupController@join');

    // 发布图片
    Route::post('/post/album', 'AlbumArticleController@add');

    // 发布文章
    Route::post('/post/content', 'ContentArticleController@add');

});

// 不需要登录的接口
Route::middleware([])->group(function () {
    Route::get('help', function (Request $request){
        return $request->json('info', $request->method());
    });

    // 圈子列表
    Route::get('/group','GroupController@list');

    // 圈子里面的文章列表
    Route::get('/group/{id}', 'GroupController@articleList');

    // 文章列表
    Route::get('/article', 'ArticleController@list');
});

// api登录相关
Route::group([

    'prefix' => 'auth'

], function ($router) {

    // 注册
    Route::post('login', 'ApiAuthController@login');

    // 登出
    Route::post('logout', 'ApiAuthController@logout');

    // 刷新token
    Route::post('refresh', 'ApiAuthController@refresh');
//    Route::post('me', 'ApiAuthController@me');

    // 注册
    Route::post('register','ApiAuthController@register');




});

